package com.huawei.appmarket.service.settings.view.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.activity.BaseActivity;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse$LevelBean;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse.GradeData;
import java.util.List;
import o.azb;
import o.der.a;
import o.der.d;
import o.der.f;
import o.der.g;
import o.CollectCheck;
import o.eqx;

public class GradeListDescriptionActivity extends BaseActivity<GradeListDescriptionActivityProtocol> {
    private GradeData ˊॱ;
    private List<GeneralResponse$LevelBean> ˏॱ;

    static class c implements OnPreDrawListener {
        private boolean ˊ;
        private TextView ˋ;
        private TextView ˎ;
        private String ˏ;

        public c(TextView textView, TextView textView2, String str, boolean z) {
            this.ˋ = textView;
            this.ˎ = textView2;
            this.ˏ = str;
            this.ˊ = z;
        }

        public boolean onPreDraw() {
            CharSequence substring = this.ˏ.substring(this.ˋ.getLayout().getLineEnd(0), this.ˏ.length());
            if (TextUtils.isEmpty(substring)) {
                this.ˎ.setVisibility(8);
            } else if (this.ˊ) {
                this.ˎ.setVisibility(0);
                this.ˋ.setVisibility(8);
                this.ˎ.setText(this.ˏ);
            } else {
                this.ˎ.setVisibility(0);
                this.ˎ.setText(substring);
            }
            this.ˋ.getViewTreeObserver().removeOnPreDrawListener(this);
            return false;
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        getWindow().setBackgroundDrawableResource(a.ᐝ);
        setContentView(g.ˋᐝ);
        GradeListDescriptionActivityProtocol gradeListDescriptionActivityProtocol = (GradeListDescriptionActivityProtocol) ʾ();
        if (gradeListDescriptionActivityProtocol == null || gradeListDescriptionActivityProtocol.ॱ() == null) {
            finish();
            return;
        }
        this.ˊॱ = gradeListDescriptionActivityProtocol.ॱ().ˊ();
        if (this.ˊॱ == null) {
            finish();
            return;
        }
        this.ˏॱ = this.ˊॱ.ॱ();
        ॱ(getString(f.ˊʼ));
        ˏ(LayoutInflater.from(this));
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        finish();
        return true;
    }

    private void ˏ(LayoutInflater layoutInflater) {
        azb.ˏ(findViewById(d.ʴ));
        LinearLayout linearLayout = (LinearLayout) findViewById(d.ॱꓸ);
        ((TextView) findViewById(d.ߵ)).setText(getString(f.ॱꜟ).substring(6));
        if (!CollectCheck.isEmpty(this.ˏॱ)) {
            for (int i = 0; i < this.ˏॱ.size(); i++) {
                View inflate = layoutInflater.inflate(g.ˌ, null);
                TextView textView = (TextView) inflate.findViewById(d.ᴵ);
                ImageView imageView = (ImageView) inflate.findViewById(d.ߴ);
                if (i == this.ˏॱ.size() - 1) {
                    ((ImageView) inflate.findViewById(d.ˊʼ)).setVisibility(4);
                }
                textView.setText(((GeneralResponse$LevelBean) this.ˏॱ.get(i)).ˎ());
                if (TextUtils.isEmpty(((GeneralResponse$LevelBean) this.ˏॱ.get(i)).ˋ())) {
                    ((LinearLayout) inflate.findViewById(d.ʿॱ)).setVisibility(8);
                } else {
                    textView = (TextView) inflate.findViewById(d.ˋʼ);
                    TextView textView2 = (TextView) inflate.findViewById(d.ʼʻ);
                    textView.setText(((GeneralResponse$LevelBean) this.ˏॱ.get(i)).ˋ());
                    ॱ(textView, textView2, ((GeneralResponse$LevelBean) this.ˏॱ.get(i)).ˋ());
                }
                eqx.ˏ(imageView, ((GeneralResponse$LevelBean) this.ˏॱ.get(i)).ˊ(), "defaultPresetResourceKey");
                linearLayout.addView(inflate);
            }
        }
    }

    private void ॱ(TextView textView, TextView textView2, String str) {
        if (!TextUtils.isEmpty(str)) {
            textView.getViewTreeObserver().addOnPreDrawListener(new c(textView, textView2, str, false));
        }
    }
}
